import base.CashContext;

import javax.lang.model.element.NestingKind;
import java.util.Scanner;

/**
 * 策略者模式注重与封装了算法。
 *
 * @author Seon
 * @date 2022/10/28 16:39
 */
public class StrategyClient {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double total = 0, acceptMoney;

        while (true) {
            System.out.println("请输出商品单价 数量 折扣方式");
            String s = in.nextLine();
            String[] split = s.split(" ");

            double price = Double.parseDouble(split[0]);
            int count = Integer.parseInt(split[1]);
            String mode = split[2];

            if (mode.equals("exit")) {
                break;
            }

            acceptMoney = new CashContext(Integer.parseInt(mode))
                    .calculate(price, count);
            total += acceptMoney;

            System.out.println("本次应收现金" + acceptMoney + "总共" + total);
        }
    }
}
